/*
var, let, const
function
class, import
*/

// 解构赋值

// 数组解构  ...Rest element
// let a = 1
// let b = 23
// let c = 99
// let [a, b, c] = [1, 23, 99, 100]
// console.log(a)
// console.log(b)
// console.log(c)

// const arr = ["奔驰", "宝马", "奥迪", ["雷克萨斯", "丰田"]]
// const [a] = arr
// const [a, , b] = arr
// console.log(a)
// console.log(b) //
// const [,,, [,a]] = arr
// console.log(a)

// const arr = ["奔驰", "宝马", "奥迪", ["雷克萨斯", "丰田"]]
// const [a, b, ...other] = arr
// const [a, b, ...other] = arr
// ...Rest element
// console.log(a)
// console.log(other)
// console.log(c)

// const [a = "默认值", b = "b的默认值"] = [99]
// const [a = "默认值", b = "b的默认值"] = [99, undefined]
// const [a = "默认值", b = "b的默认值"] = [99, null]
// console.log(a)
// console.log(b)

// 对象的解构 {} = {}

const person = {
	uname: "张三",
	age: 23,
	sayHi: function() {
		console.log("hi")
	},
	keyA: {
		a: "aaaa"
	}
}
// ...rest 操作符可以实现对象浅拷贝
// const { uname: u, ...other } = person
const { ...other } = person

// console.log(u)
other.uname = "other"
other.keyA.a = "other aaa"
console.log(other)
console.log("person", person)


// const { sayHi, name, age } = person
// console.log(name)
// console.log(age)
// sayHi()

// const { uname: username } = person
// const { 属性: 最终的变量名 } = person
// 解构对象属性重命名
// console.log(uname)
// console.log(username)
/*
const { 
	x = "x默认值",
	x: y,
	// uname = "lisi"
	uname: u = "lisi"
} = {
	x: 123,
	// uname: "李四"
	// uname: undefined
	uname: null
}
console.log(x)
console.log(y)
// console.log(uname)
console.log(u)
*/
